<!doctype html>
<meta charset=utf-8>
<title>Perf Tests</title>

<script>
window.onerror = function(error){
  window._unhandledError = error;
  window.isDone = true;
}
</script>

<script src="./lib/perf-test-runner.browser.js"></script>
<script> perfRunner.Polyfill(); </script>
<script src="../build/react.js"></script>
<script src="../build/JSXTransformer.js"></script>
<script src="../test/lib/postDataToURL.browser.js"></script>
<script src="./lib/BrowserPerfRunnerContext.react.js"></script>
<script src="./lib/BrowserPerfRunnerApp.react.js"></script>

<script>

var tests = [
  "sanity.js",
  "todolist-mount.js",
  "todolist-edit.js",
  "todolist-add.js",
  "todolist-do-stuff.js",
  "setState-callback-5.js",
  "setState-callback.js",
  "basic-div.js",
  "basic-unmount.js",
  "propTypes.js",
  "renderComponent-basic.js",
  "shouldComponentUpdate.js",
];

var reactVersions = [
  'edge',
  'builds/master/latest'
];

window.onload = function(){
  window.isDone = false;

  React.renderComponent(
    BrowserPerfRunnerApp({
      headless: perfRunner.getQueryParamArrayOrDefault('headless', [false])[0],
      react: perfRunner.getQueryParamArrayOrDefault('react', reactVersions),
      tests: perfRunner.getQueryParamArrayOrDefault('test', tests),
      maxTime: perfRunner.getQueryParamArrayOrDefault('maxTime', [5])[0],
      onCompleteEach: function(results){
        console.log('onCompleteEach', results);
        postDataToURL({type:'perf', message:results}, '/reportTestResults');
      },
      onError: function(error){
        window._unhandledError = error;
      },
      onComplete: function(results){
        window.completedTestKeys = Object.keys(results);
        window.isDone = true;
      }
    }),
    document.body
  );
}

</script>
